package com.baymax.lib.replace




/**
 * 字符串内容替换器
 */
open class StringElementReplacer: ReplacerFunction<String, String>() {
    private val TAG = "StringElementReplacer"

    /**
     * 收集${xxx}这种格式的内容
     */
    override fun finder(str:String): List<String> {
        val list =  mutableListOf<String>()
        var start = 0
        var end = 0
        do {
            start = end
            start = str.indexOf("${'$'}{",start)
            end = str.indexOf("}",start)
            if (start < end && start != -1 && end != -1) {
                val string = str.substring(start, end + 1)
                if (!list.contains(string)) list.add(string)
            }
        }while(start < end && start != -1 && end != -1)
        return list
    }



}